package com.itheima.serviceImpl;

import com.itheima.entity.Count;
import com.itheima.entity.CountClazzList;
import com.itheima.entity.CountJobList;
import com.itheima.mapper.CountMapper;
import com.itheima.service.CountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CountServiceImpl implements CountService {

    @Autowired
    CountMapper countMapper;

    @Override
    public List<Count> getEmpGenderData() {
        return countMapper.getEmpGenderData();
    }

    @Override
    public CountJobList getEmpJobData() {

        List<Count> empJobData = countMapper.getEmpJobData();
        CountJobList countJobList = new CountJobList();
        List<String> jobList = countJobList.getJobList();
        List<Integer> dataList = countJobList.getDataList();

        empJobData.forEach((empJob)->{
            jobList.add(empJob.getName());
            dataList.add(empJob.getValue());
        });
        return countJobList;
    }

    @Override
    public List<Count> getStudentDegreeData() {

        return countMapper.getStudentDegreeData();
    }

    @Override
    public CountClazzList getStudentClazzData() {
        List<Count> studentClazzData = countMapper.getStudentClazzData();
        CountClazzList countClazzList = new CountClazzList();
        List<String> clazzList = countClazzList.getClazzList();
        List<Integer> dataList = countClazzList.getDataList();

        studentClazzData.forEach((studentClazz)->{
            clazzList.add(studentClazz.getName());
            dataList.add(studentClazz.getValue());
        });
        return countClazzList;
    }
}
